Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make big model inference compatible with torch.compile #2609

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

SunMarc
Copy link
Member

@SunMarc SunMarc commented Apr 2, 2024

What does this PR do ?

This PR makes big model inference compatible with torch.compile. To do that, we need to fix send_to_device.

In pytorch 2.2.1, hasattr is not implemented for TupleVariable, so we get an error in is_namedtuple function. I tried a few methods to not use hasattr but I didn't manage to make it work (e.g. try except block). If we bypass the is_namedtuple function, compile works fine. In pytorch nightly (future 2.4), this is implemented but we hit another error ( breaking changes ... ). So, I need to investigate more.

Fixes #2592
Draft for now to not forget

EDIT: Feel free to try this PR. It should work for the latest torch. However, it doesn't support namedtuple.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@muellerzr muellerzr added the wip Work in progress label Apr 2, 2024
@Aknifejackzhmolong
Copy link

Hi, I've hit the exact same error. Any news on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

torch.compile not working with device_map and multiple GPUs
4 participants